home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / INTERACT.H < prev    next >
C/C++ Source or Header  |  1992-02-25  |  6KB  |  211 lines

  1. /*
  2.  * Base class for interactive objects.
  3.  */
  4.  
  5. #ifndef interactor_h
  6. #define interactor_h
  7.  
  8. #include <Interviews\defs.h>
  9.  
  10. /* these are obsolete and should not be used */
  11. extern class Sensor* stdsensor;
  12. extern class Painter* stdpaint;
  13. #ifdef _3D
  14. extern class Painter3D* stdpaint3D;
  15. #endif
  16.  
  17. enum CanvasType {
  18.     CanvasShapeOnly, CanvasInputOnly, CanvasInputOutput,
  19.     CanvasSaveUnder, CanvasSaveContents, CanvasSaveBoth
  20. };
  21.  
  22. enum InteractorType {
  23.     InteriorInteractor, PopupInteractor, TransientInteractor,
  24.     ToplevelInteractor, ApplicationInteractor, IconInteractor
  25. };
  26.  
  27. #ifdef _3D
  28. class Painter3D;
  29. #endif
  30.  
  31. class Bitmap;
  32. class Canvas;
  33. class Cursor;
  34. class Event;
  35. class Perspective;
  36. class Scene;
  37. class Shape;
  38. class StringId;
  39. class TopLevel;
  40. class World;
  41. class WindowData;
  42.  
  43. class Interactor {
  44. public:
  45.     Interactor();
  46.     Interactor(const char*);
  47.     virtual ~Interactor();
  48.  
  49.     /* configuration */
  50.     void Align(Alignment, int w, int h, Coord& l, Coord& b);
  51.     void Config(Scene* = nil);
  52.     virtual void Reconfig();
  53.     const char* GetAttribute(const char*);
  54.     virtual void Reshape(Shape&);
  55.     Shape* GetShape();
  56.     void SetCursor(Cursor*);
  57.     Cursor* GetCursor();
  58.     const char* GetClassName();
  59.     const char* GetInstance();
  60.  
  61.     /* traversing hierarchy */
  62.     virtual void GetComponents(Interactor**, int, Interactor**&, int&);
  63.     void GetRelative(Coord& x, Coord &y, Interactor* = nil);
  64.     Scene* Parent();
  65.     Scene* Root();
  66.     World* GetWorld();
  67.  
  68.     /* output */
  69.     Canvas* GetCanvas();
  70.     virtual void Draw();
  71.     virtual void Highlight(boolean on);
  72.  
  73.     /* input events */
  74.     boolean Check();
  75.     int CheckQueue();
  76.     void Flush();
  77.     virtual void Handle(Event&);
  78.     void Listen(Sensor*);
  79.     void Poll(Event&);
  80.     void Read(Event&);
  81.     void Run();
  82.     void QuitRunning(Event&);
  83.     void Sync();
  84.     void UnRead(Event&);
  85.  
  86.     /* subject-view communication */
  87.     virtual void Adjust(Perspective&);
  88.     Perspective* GetPerspective();
  89.     virtual void Update();
  90.  
  91.     /* top-level interactors */
  92.     void SetName(const char*);
  93.     const char* GetName();
  94.     void SetGeometry(const char*);
  95.     const char* GetGeometry();
  96.     void SetCanvasType(CanvasType);
  97.     CanvasType GetCanvasType();
  98.     void SetInteractorType(InteractorType);
  99.     InteractorType GetInteractorType();
  100.     void SetGroupLeader(Interactor*);
  101.     Interactor* GetGroupLeader();
  102.     void SetTransientFor(Interactor*);
  103.     Interactor* GetTransientFor();
  104.  
  105.     /* icons */
  106.     void SetIconName(const char*);
  107.     const char* GetIconName();
  108.  
  109.     void SetIconInteractor(Interactor*);
  110.     Interactor* GetIconInteractor();
  111.  
  112.     void SetIconGeometry(const char*);
  113.     const char* GetIconGeometry();
  114.  
  115.     void SetIconBitmap(Bitmap*);
  116.     Bitmap* GetIconBitmap();
  117.  
  118.     void SetIconMask(Bitmap*);
  119.     Bitmap* GetIconMask();
  120.  
  121.     void SetStartIconic(boolean);
  122.     boolean GetStartIconic();
  123.  
  124.     void PlaceIcon(Interactor*, Canvas*&);
  125.  
  126.     void Iconify();
  127.     void DeIconify();
  128.  
  129.     /* obsolete -- use Set/GetIconInteractor */
  130.     void SetIcon(Interactor*);
  131.     Interactor* GetIcon();
  132.  
  133. protected:
  134.     Shape* shape;                       /* desired shape characteristics */
  135.     Canvas* canvas;                     /* actual display area */
  136.     Perspective* perspective;           /* portion displayed */
  137.     Coord xmax;                         /* canvas->Width() - 1 */
  138.     Coord ymax;                         /* canvas->Height() - 1 */
  139.     Sensor* input;                      /* normal input event interest */
  140. #ifdef _3D
  141.     Painter3D* output3D;
  142. #endif
  143.     Painter* output;                    /* normal output parameters */
  144.  
  145.     Interactor(Sensor*, Painter*);      /* old-fashioned constructor */
  146.  
  147.     virtual void Redraw(Coord left, Coord bottom, Coord right, Coord top);
  148.     virtual void RedrawList(int n, Coord[], Coord[], Coord[], Coord[]);
  149.     virtual void Resize();
  150.  
  151.     virtual void Activate();
  152.     virtual void Deactivate();
  153.  
  154.     void SetClassName(const char*);
  155.     void SetInstance(const char*);
  156.     void RootConfig();
  157.     boolean IsMapped();
  158. private:
  159.     friend class Scene;
  160.     friend class Canvas;
  161.     friend class World;
  162.     friend class Interactor;      // !-!
  163.  
  164.     Scene* parent;                      /* where inserted */
  165.     StringId* classname;                /* class for attributes */
  166.     StringId* instance;                 /* instance for attributes */
  167.     TopLevel* toplevel;                 /* top-level interactor parameters */
  168.     Coord left;                         /* relative to parent */
  169.     Coord bottom;                       /* relative to parent */
  170.     Sensor* cursensor;                  /* current input interest */
  171.  
  172.     WindowData* rep;
  173.  
  174.     void Init();
  175.     void DefaultConfig(boolean&);
  176.     void DoConfig(boolean);
  177.  
  178.     void GetOrigin(Coord&, Coord&);
  179.     TopLevel* GetTopLevel();
  180.     void DoSetCursor(Cursor*);
  181.     void DoSetName(const char*);
  182.     void DoSetGeometry();
  183.     void DoSetGroupLeader(Interactor*);
  184.     void DoSetTransientFor(Interactor*);
  185.     void DoSetIconName(const char*);
  186.     void DoSetIconInteractor(Interactor*);
  187.     void DoSetIconGeometry(const char*);
  188.     void DoSetIconBitmap(Bitmap*);
  189.     void DoSetIconMask(Bitmap*);
  190.  
  191.     int Fileno();
  192.  
  193.     void DiscardUnreadEvents();
  194.     boolean Select(Event&);
  195.     virtual boolean GetEvent(Event&, boolean);
  196.     void SendRedraw();
  197.     void SendResize(Coord x, Coord y, int width, int height);
  198.     void SendActivate();
  199.     void SendDeactivate();
  200. };
  201.  
  202. inline Canvas* Interactor::GetCanvas() { return canvas; }
  203. inline Scene* Interactor::Parent () { return parent; }
  204. inline Perspective* Interactor::GetPerspective () { return perspective; }
  205. inline Shape* Interactor::GetShape () { return shape; }
  206.  
  207. inline void Interactor::SetIcon (Interactor* i) { SetIconInteractor(i); }
  208. inline Interactor* Interactor::GetIcon () { return GetIconInteractor(); }
  209.  
  210. #endif
  211.